package com.bdqn.systems.auth;

import com.bdqn.response.Result;
import com.bdqn.response.ResultCode;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @author : CP
 * @version: 1.0
 * @program : xinguan-parent
 * @description :
 * @date : 2020-12-23 10:01
 **/
public class MyExpiredSessionStrategy extends JSONAuthentication implements SessionInformationExpiredStrategy {

    /**
     * 过期会话
     * @param sessionInformationExpiredEvent
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) throws IOException, ServletException {
        Result error = Result.error(ResultCode.USER_ACCOUNT_EXPIRED);
        this.WriteJSON(sessionInformationExpiredEvent.getRequest(),sessionInformationExpiredEvent.getResponse(),error);
    }
}
